package com.hs.libs.mobile;

import com.hs.libs.BaseUITasks;
import org.apache.log4j.Logger;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

import java.util.List;

/**
 * iOS UI 自动化测试任务， app: com.ookla.speedtest
 */
public class IOSUITasks extends BaseUITasks {
    private static Logger logger = Logger.getLogger(IOSUITasks.class);

    public static void clickNextBtn(WebDriver driver) throws Exception {
        List<WebElement> btnEles =
                findObjectsByXPath("//XCUIElementTypeStaticText[@name=\"Next\"]", driver);
        if (btnEles != null && btnEles.size() > 0) {
            logger.info("Next按钮元素可以被定位成功！");
        }
        logger.info("单击Next按钮");
        btnEles.get(0).click();
    }

    public static boolean isContinueBtnExist(WebDriver driver) throws Exception {
        boolean result = false;
        List<WebElement> btnEles =
                findObjectsByXPath("//XCUIElementTypeStaticText[@name=\"Continue\"]", driver);
        if (btnEles != null && btnEles.size() > 0) {
            result = true;
            logger.info("Continue 按钮元素可以被定位成功！");
        }
        return result;
    }
}
